using System.Collections;
using Anvil.Core;
using IBatisNet.DataMapper;

namespace Anvil.Extras.IBatisNet
{
	/// <summary>
	/// Implement DataMapper using iBATIS SqlMapper.
	/// </summary>
	/// <remarks>
	/// This is a simple proxy class that just calls through to SqlMapper. 
	/// The value-add is that the class decouples iBATIS 
	/// from the Nexus base commands.
	/// The SqlMapper can be injected to this class, 
	/// and then this class can be injected into the BaseMapper.
	/// </remarks>
	public class DataMapper : IDataMapper
	{
		
		private SqlMapper _SqlMapper;
		
		public SqlMapper InitMapper
		{
			get { return _SqlMapper; }
			set { _SqlMapper = value; }
		}

				
		public object QueryForObject(string statementName, object parameterObject)
		{
            return InitMapper.QueryForObject(statementName, parameterObject);
		}

		public object QueryForObject(string statementName, object parameterObject, object resultObject)
		{
            return InitMapper.QueryForObject(statementName, parameterObject, resultObject);
		}

		public IDictionary QueryForDictionary(string statementName, object parameterObject, string keyProperty)
		{
            return InitMapper.QueryForDictionary(statementName, parameterObject, keyProperty);
		}

		public IDictionary QueryForDictionary(string statementName, object parameterObject, string keyProperty,
			string valueProperty)
		{
            return InitMapper.QueryForDictionary(statementName, parameterObject, keyProperty, valueProperty);
		}

		public IDictionary QueryForMap(string statementName, object parameterObject, string keyProperty)
		{
            return InitMapper.QueryForMap(statementName, parameterObject, keyProperty);
		}

		public IDictionary QueryForMap(string statementName, object parameterObject, string keyProperty, string valueProperty)
		{
            return InitMapper.QueryForMap(statementName, parameterObject, keyProperty, valueProperty);
		}

		public IList QueryForList(string statementName, object parameterObject)
		{
            return InitMapper.QueryForList(statementName, parameterObject);
		}

		public IList QueryForList(string statementName, object parameterObject, int skipResults, int maxResults)
		{
			return QueryForList(statementName, parameterObject, skipResults, maxResults);
		}

		public void QueryForList(string statementName, object parameterObject, IList resultObject)
		{
			QueryForList(statementName, parameterObject, resultObject);
		}

		public object Insert(string statementName, object parameterObject)
		{
			return InitMapper.Insert(statementName, parameterObject);
		}

		public int Update(string statementName, object parameterObject)
		{
            return InitMapper.Update(statementName, parameterObject);
		}

		public int Delete(string statementName, object parameterObject)
		{
            return InitMapper.Delete(statementName, parameterObject);
		}
	}
}
